<?php session_start();?>
<html>
<body>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<?php
require('../public/conn.php');
$message = trim($_POST["message"]);//得到内容
$timestamp = time();//得到提交时间戳
$from = $_SESSION['username'];	//得到发送留言者
$to = $_GET['to'];//得到接受留言者
$belong_to = $_GET['belong_to'];
$query = "";
if($belong_to == 1){	//不属于谁，即不是楼中楼
	$query="INSERT INTO messages (send_from,send_to,time_stamp,message,belong_to) VALUES ('$from','$to','$timestamp','$message','1')";
}else{
	$query="INSERT INTO messages (send_from,send_to,time_stamp,message,belong_to) VALUES ('$from','$to','$timestamp','$message','$belong_to')";
}
mysql_query($query);//插入数据库
mysql_close($con);
header("location: ../home/friends.php");//跳转回首页
?>
<?php require('../public/footer.php');?>
</body>
</html>